package web.servlet.doctor;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;

import service.DoctorServiceImpl;
import domain.Doctor;

public class UpdateDoctorServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		Doctor doctor = new Doctor();
		try {
			BeanUtils.populate(doctor, request.getParameterMap());
		} catch (Exception e) {
			e.printStackTrace();
		}

		DoctorServiceImpl ds = new DoctorServiceImpl();
		ds.updateDoctor(doctor);
		
		
		//跳转
		request.getRequestDispatcher("/doctor/doctorListServlet").forward(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
